﻿using System;
using System.Collections.Generic;
using AIProject.Utility;

namespace AIProject.Pylos
{
    class Piece
    {
        private Boolean whiteOwner;
        private Point point;
        private int supporting;

        public Boolean OwnedByWhite
        {
            get
            {
                return this.whiteOwner;
            }
            set
            {
            }
        }

        public Boolean Moveable
        {
            get
            {
                return this.supporting == 0;
            }
            set
            {
            }
        }

        public Point Location
        {
            get
            {
                return this.point;
            }

            set
            {
            }
        }

        public int Supporting
        {
            get
            {
                return this.supporting;
            }
            set
            {
                this.supporting = value;
            }
        }

        public Piece(Boolean whiteOwner, int x, int y)
        {
            this.whiteOwner = whiteOwner;
            this.supporting = 0;

            this.point = new Point(x, y);
        }

        private Piece(Boolean whiteOwner, int supporting, Point p)
        {
            this.whiteOwner = whiteOwner;
            this.supporting = supporting;

            this.point = p;
        }

        public Object clone()
        {
            return new Piece(whiteOwner, supporting, new Point(point.X, point.Y));
        }

        public override string ToString()
        {
            return (this.OwnedByWhite ? "W" : "B");
        }

        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return false;
            }

            Piece p = obj as Piece;

            if (p != null)
            {
                return (p.Location.X == this.Location.X && p.Location.Y == this.Location.Y);
            }
            else
            {
                return false;
            }
        }

        public override int GetHashCode()
        {
            return base.GetHashCode();
        }
    }
}
